﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Renci.iRods.Common;

namespace Renci.iRods.Packets
{
    //  API 681
    //#define CollInpNew_PI "str collName[MAX_NAME_LEN]; int flags; int oprType; struct KeyValPair_PI;"
    [Packet("CollInpNew_PI")]
    internal class CollectionInputNewPacket : Packet
    {
        private IDictionary<string, string> _keyValues = new Dictionary<string, string>();

        [PacketField("collName", 0, DataTypes.String, 1024)]
        public string CollectionName { get; private set; }

        [PacketField("flags", 1, DataTypes.Int)]
        public int Flags { get; private set; }

        [PacketField("oprType", 2, DataTypes.Int)]
        public int OperationType { get; private set; }

        [PacketField("KeyValPair_PI", 3, DataTypes.Packet)]
        public KeyValuePairPacket KeyValuePair
        {
            get
            {
                return new KeyValuePairPacket(this._keyValues);
            }
        }

        public CollectionInputNewPacket(string collectionName)
        {
            this.CollectionName = collectionName;
        }

        public void AddKey(string key)
        {
            this.AddKey(key, string.Empty);
        }

        public void AddKey(string key, string value)
        {
            this._keyValues.Add(key, value);
        }

    }
}


